<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Priithon.usefulGeo</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="Priithon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/priithon">Priithon</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="Priithon-module.html">Package&nbsp;Priithon</a> ::
        Module&nbsp;usefulGeo
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="Priithon.usefulGeo-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module usefulGeo</h1><p class="nomargin-top"><span class="codelink"><a href="Priithon.usefulGeo-pysrc.html">source&nbsp;code</a></span></p>
<p>a bunch of 2d geometry functions</p>
  <p>points are always defined as y,x tuples or numpy arrays segments are 
  sequences of pairs-of-nodes boxes are a sequence of two diagonal 
  edge-points</p>

<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.usefulGeo-module.html#geoPointsEq" class="summary-sig-name">geoPointsEq</a>(<span class="summary-sig-arg">yx0</span>,
        <span class="summary-sig-arg">yx1</span>,
        <span class="summary-sig-arg">eps</span>=<span class="summary-sig-default">0.01</span>)</span><br />
      are two points equal ...</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointsEq">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="geoSegEqOpposite"></a><span class="summary-sig-name">geoSegEqOpposite</span>(<span class="summary-sig-arg">s0</span>,
        <span class="summary-sig-arg">s1</span>,
        <span class="summary-sig-arg">eps</span>=<span class="summary-sig-default">0.01</span>)</span><br />
      are two segments equals and oppositely directed</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoSegEqOpposite">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.usefulGeo-module.html#geoPointSeqSide" class="summary-sig-name">geoPointSeqSide</a>(<span class="summary-sig-arg">p</span>,
        <span class="summary-sig-arg">seg</span>)</span><br />
      determine on which side of a segment a given point lies</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointSeqSide">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="geoBoxToSegs"></a><span class="summary-sig-name">geoBoxToSegs</span>(<span class="summary-sig-arg">edges</span>)</span><br />
      return list of 4 seqments of box defined by its two edges</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoBoxToSegs">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="geoPointLineDist"></a><span class="summary-sig-name">geoPointLineDist</span>(<span class="summary-sig-arg">p</span>,
        <span class="summary-sig-arg">seg</span>,
        <span class="summary-sig-arg">testSegmentEnds</span>=<span class="summary-sig-default">False</span>)</span><br />
      Minimum Distance between a Point and a Line Written by Paul Bourke,
      October 1988 
      http://astronomy.swin.edu.au/~pbourke/geometry/pointline/</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointLineDist">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="geoPointSegsDist"></a><span class="summary-sig-name">geoPointSegsDist</span>(<span class="summary-sig-arg">p</span>,
        <span class="summary-sig-arg">segs</span>)</span><br />
      smallest distance of a point to a sequence of line segments</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointSegsDist">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="geoPointInsideBox"></a><span class="summary-sig-name">geoPointInsideBox</span>(<span class="summary-sig-arg">p</span>,
        <span class="summary-sig-arg">edges</span>)</span><br />
      returns True only if p lies inside or on the sides of box</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointInsideBox">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="geoSeqsBoundingBox"></a><span class="summary-sig-name">geoSeqsBoundingBox</span>(<span class="summary-sig-arg">segs</span>)</span><br />
      return corners (LB+TR) of smallest box containing all segments in 
      segs</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoSeqsBoundingBox">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.usefulGeo-module.html#geoPointsBoundingBox" class="summary-sig-name">geoPointsBoundingBox</a>(<span class="summary-sig-arg">points</span>,
        <span class="summary-sig-arg">intCoords</span>=<span class="summary-sig-default">False</span>)</span><br />
      return corners (LB+TR) of smallest box containing all points...</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointsBoundingBox">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.usefulGeo-module.html#geoGetPointsOfCenteredBox" class="summary-sig-name">geoGetPointsOfCenteredBox</a>(<span class="summary-sig-arg">cyx</span>,
        <span class="summary-sig-arg">sy</span>,
        <span class="summary-sig-arg">sx</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">clockwise</span>=<span class="summary-sig-default">False</span>)</span><br />
      return list of 4 pt-pairs 4 corners of box centered at `cyx`, side 
      lengths are `sy`, `sx` if `sx` is None, it defaults to `sy`</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoGetPointsOfCenteredBox">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.usefulGeo-module.html#geoGetPointsOfBox" class="summary-sig-name">geoGetPointsOfBox</a>(<span class="summary-sig-arg">yx0</span>,
        <span class="summary-sig-arg">yx1</span>,
        <span class="summary-sig-arg">clockwise</span>=<span class="summary-sig-default">False</span>)</span><br />
      return list of 4 pt-pairs 4 corners of box with corners yx0, yx1 side
      lengths are `sy`, `sx` if `sx` is None, it defaults to `sy`</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoGetPointsOfBox">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="geoPointsEq"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">geoPointsEq</span>(<span class="sig-arg">yx0</span>,
        <span class="sig-arg">yx1</span>,
        <span class="sig-arg">eps</span>=<span class="sig-default">0.01</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointsEq">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">

are two points equal 
  (within eps distance, x,y separately)

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="geoPointSeqSide"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">geoPointSeqSide</span>(<span class="sig-arg">p</span>,
        <span class="sig-arg">seg</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointSeqSide">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">

determine on which side of a segment a given point lies

http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/

Given a line segment between P0 (x0,y0) and P1 (x1,y1), another point P (x,y) has the following relationship to the line segment. 

Compute 
 (y - y0) (x1 - x0) - (x - x0) (y1 - y0)

if it is less than 0 then P is to the right of the line segment, if greater than 0 it is to the left, if equal to 0 then it lies on the line segment.

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="geoPointsBoundingBox"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">geoPointsBoundingBox</span>(<span class="sig-arg">points</span>,
        <span class="sig-arg">intCoords</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoPointsBoundingBox">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">

return corners (LB+TR) of smallest box containing all points
if intCoords:
    use int(...) for lower and int(...)+1 for upper bounds

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="geoGetPointsOfCenteredBox"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">geoGetPointsOfCenteredBox</span>(<span class="sig-arg">cyx</span>,
        <span class="sig-arg">sy</span>,
        <span class="sig-arg">sx</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">clockwise</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoGetPointsOfCenteredBox">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>return list of 4 pt-pairs 4 corners of box centered at `cyx`, side 
  lengths are `sy`, `sx` if `sx` is None, it defaults to `sy`</p>
  <p>if clockwise: 2nd and 4th point will be swapped (-&gt; mathematical 
  negatve order)</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="geoGetPointsOfBox"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">geoGetPointsOfBox</span>(<span class="sig-arg">yx0</span>,
        <span class="sig-arg">yx1</span>,
        <span class="sig-arg">clockwise</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.usefulGeo-pysrc.html#geoGetPointsOfBox">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>return list of 4 pt-pairs 4 corners of box with corners yx0, yx1 side 
  lengths are `sy`, `sx` if `sx` is None, it defaults to `sy`</p>
  <p>if clockwise: 2nd and 4th point will be swapped (-&gt; mathematical 
  negatve order)</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="Priithon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/priithon">Priithon</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Nov 22 14:59:33 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
